package com.xca.znb.presenter;

import com.xca.znb.entity.Collect;
import com.xca.znb.entity.Goods;
import com.xca.znb.entity.NewsLetter;
import com.xca.znb.entity.Procurement;
import com.xca.znb.entity.User;
import com.xca.znb.model.imodel.IEnterStore;

import java.util.List;

public class EnterStorePresenter {
    private IEnterStore iEnterStore ;
    public EnterStorePresenter( IEnterStore iEnterStore){
        this.iEnterStore = iEnterStore ;
    }

    public User getUser(String phone){
        return iEnterStore.getUserByPhone(phone);
    }

    public List<Goods> getGoodsByPhone(String phone){
        return iEnterStore.getGoodsByPhone(phone);
    }
    public List<Procurement> getProcurementByPhone(String phone){
        return iEnterStore.getProcurementByPhone(phone);
    }
    public void addNewsletter(String phone1 , String phone2 , String time){
        NewsLetter newsLetter = iEnterStore.getNewsLetterByPhone(phone1, phone2);
        NewsLetter newsLetter1 = iEnterStore.getNewsLetterByPhone(phone2 , phone1);
        if (newsLetter == null && newsLetter1 == null){
            iEnterStore.addNewsletter(phone1, phone2, time);
        }
    }

    public void addCollect(String gId, String type, String user) {
        iEnterStore.addCollect(gId, type, user);
    }

    public void delCollect(int id) {
        iEnterStore.delCollect(id);
    }

    public Collect getCollect(String gId, String type, String user) {
        return iEnterStore.getCollect(gId, type, user);
    }
    public void addOrUpdateFoot(int goodsId, String user, String time) {
        iEnterStore.addOrUpdateFoot(goodsId,user,time);
    }
}
